#include "guiplugin2.h"

#include <QListWidget>
#include <pluginui/manager/AbstractPanelManager.h>
#include <plugin/plugin/PluginFactory.h>
#include "GuiPlugin2ConfigPanel.h"

Guiplugin2::Guiplugin2(PluginDescriptionSharedPtr pDescription, ServiceRegistry* pServiceRegistry)
    : GuiPlugin(pDescription, pServiceRegistry)
{
}

void Guiplugin2::doStartMenu(AbstractMenuManager *pMenuManager)
{

}

void Guiplugin2::doStartToolBar(AbstractToolBarManager *pToolBarManager)
{

}

void Guiplugin2::doStartContentPanel(AbstractPanelManager *pContentPanelManager)
{

}

void Guiplugin2::doStartSidePanel(AbstractPanelManager *pSidePanelManager)
{
    AbstractPanelContainer* pContainer = pSidePanelManager->container("Test3");

    if (pContainer != nullptr)
    {
        QListWidget* pWidget3 = new QListWidget();
        pWidget3->addItem("4");
        pWidget3->addItem("5");
        pWidget3->addItem("6");
        pWidget3->setWindowTitle("List 4");
        pContainer->addPanel("List4", pWidget3);
    }

    pContainer = pSidePanelManager->container("Test4", "Test 4", AbstractPanelManager::PT_VBox,
                                              Qt::LeftDockWidgetArea);
    if (pContainer != nullptr)
    {
        QListWidget* pWidget4 = new QListWidget();
        pWidget4->addItem("5");
        pWidget4->addItem("6");
        pWidget4->addItem("7");
        pWidget4->setWindowTitle("List 5");
        pContainer->addPanel("List5", pWidget4);
    }
}

void Guiplugin2::doStartStatusBar(AbstractStatusBarManager *pStatusBarManager)
{

}

void Guiplugin2::doStartConfigPanels(ConfigPanelManager *pConfigPanelManager)
{
    pConfigPanelManager->addItem(QIcon(":/resources/images/roller.png"), "GuiPlugin2 Config",
                                       new GuiPlugin2ConfigPanel);
}

antu::plugin::AbstractPlugin* InstantiatePlugin(antu::plugin::PluginDescriptionSharedPtr& description,
                                                antu::plugin::ServiceRegistry* pServiceRegistry)
{
    return new Guiplugin2(description, pServiceRegistry);
}

void InitFactory(const QString &code)
{
    antu::plugin::PluginFactory::Factory.registerPluginInfo(
                code,
                InstantiatePlugin);
}
